<template>
  <div style="height: 100%">
    <div>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item>
          <el-input v-model="formInline.username" placeholder="字典名"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="find" size="medium" icon="el-icon-search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="add" size="medium" icon="el-icon-plus">新增</el-button>
        </el-form-item>
      </el-form>
      <vue-table :columns="columns" :data="tableData" @findPage="findByPage" @selectionChange="selectionChange"></vue-table>
    </div>
  </div>
</template>

<script>
  import vueTable from '../../../components/vueTable.vue'
  import {dictApi} from '../../../http/modules/dict'

  export default {
    name: "dict",
    components: {
      vueTable
    },
    data() {
      return {
        tableData: {
          totalSize: 10,
          content: []
        },
        pageRequest: {
          pageNum: 1,
          pageSize: 10
        },
        columns: [
          {prop:"username", label:"名称", minWidth:100},
          {prop:"phone", label:"类型", minWidth:100},
          {prop:"email", label:"路由路径", minWidth:100},
          {prop:"dept", label:"图标", minWidth:100},
          {prop: "role", label: "角色", minWidth: 100},
          {prop: "permission", label: "授权标识", minWidth: 100},
          {prop:"lockFlag", label:"排序", minWidth:80}
        ],
        formInline: {
          username: ''
        },
        selections: [],
        dialogFormVisible: false,
        dictForm: {
          name: '',
          sort: '',
          parentId: '',
          parentName: ''
        }
      }
    },
    methods: {
      findByPage(data) {
        if (data != null) {
          this.pageRequest = data
        }
        dictApi.findPage(this.pageRequest).then(data => {
          this.tableData = data.data
        })
      },
      add() {
        this.dialogFormVisible = true
      },
      cancel() {
        this.dialogFormVisible = false
      },
      save() {
        dictApi.save(this.userForm).then(res => {
          this.$message.success('保存成功')
          this.dialogFormVisible = false
        }).catch(error => {
          this.$message.error('保存失败')
        })
      },
      selectionChange(selections) {
        this.selections = selections
      }
    },
    mounted() {
      // this.findByPage(this.pageRequest)
    }
  }
</script>

<style scoped>

</style>
